package com.edu.exam.enums.curriculum;

import com.edu.exam.enums.core.BaseEnum;

/**
 * 影响级别枚举
 *
 * @author System
 * @version 1.0.0
 */
public enum ImpactLevel implements BaseEnum {
    LOW("LOW", "低"),
    MEDIUM("MEDIUM", "中"),
    HIGH("HIGH", "高"),
    CRITICAL("CRITICAL", "严重");

    private final String code;
    private final String description;

    ImpactLevel(String code, String description) {
        this.code = code;
        this.description = description;
    }

    @Override
    public String getCode() {
        return code;
    }

    @Override
    public String getDescription() {
        return description;
    }

    public static ImpactLevel fromCode(String code) {
        if (code == null || code.trim().isEmpty()) {
            throw new IllegalArgumentException("ImpactLevel code cannot be null or empty");
        }
        for (ImpactLevel level : values()) {
            if (level.getCode().equals(code)) {
                return level;
            }
        }
        throw new IllegalArgumentException("Unknown ImpactLevel code: " + code);
    }

    public static ImpactLevel fromDescription(String description) {
        if (description == null || description.trim().isEmpty()) {
            throw new IllegalArgumentException("ImpactLevel description cannot be null or empty");
        }
        for (ImpactLevel level : values()) {
            if (level.getDescription().equals(description)) {
                return level;
            }
        }
        throw new IllegalArgumentException("Unknown ImpactLevel description: " + description);
    }

    @Override
    public String toString() {
        return this.code + "(" + this.description + ")";
    }
}